package com.chengfei.spring.cloud.weather.job;

import com.chengfei.spring.cloud.weather.service.WeatherDataCollectionService;
import com.chengfei.spring.cloud.weather.vo.City;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chengfei cheng.fei@chinaott.onaliyun.com
 **/
public class WeatherDataSyncJob extends QuartzJobBean{
    private final static Logger logger = LoggerFactory.getLogger(WeatherDataSyncJob.class);
    @Autowired
    private WeatherDataCollectionService weatherDataCollectionService;
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        logger.info("Weather Data Sync Job Start");
        //1.获取城市id列表
        //TODO 改为由城市数据API微服务来提供数据
        List<City> cityList = null;
        try{
            //TODO 改为由城市数据API微服务来提供数据
            cityList = new ArrayList<>();
            City city = new City();
            city.setCityId("101280601");
            cityList.add(city);

        }catch (Exception e){
            logger.error("Exception!",e);
        }

    }
}
